import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
//随机字符串

class RandomWordsRoute extends StatefulWidget {
  @override
  _RandomWordsRoute createState() => new _RandomWordsRoute();
}

class _RandomWordsRoute extends State<RandomWordsRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("生成随机字符串"),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text("生成随机字符串"),
              onPressed: () {
                // 刷新页面
                setState(() {});
              },
            ),
            _RandomWordsWidget(),
          ],
        ),
      ),
    );
  }
}

// english_words 生成随机数
class _RandomWordsWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final wordPair = new WordPair.random();
    return Padding(
        padding: const EdgeInsets.all(8.0),
        child: new Text(wordPair.toString()));
  }
}
